<template>
	<view class="wrap">
		<view class="content">
			<view class="item" v-for="(item, index) in articleList" :key="index" @click="gotoDetail(item.id)">
				<view class="head">
					<image src="../../static/logo.png"></image>
					<view>
						<text>{{item.author}}</text>
						<text>{{item.time}}</text>
					</view>
					
				</view>
				
				<view class="text_content">
					<view class="content_main">
						<view class="title">
							{{item.title}}
						</view>
						<view class="list">
							{{item.description}}
						</view>
					</view>
				</view>
			</view>
			
			
				
			</view>
			
		</view>
	</view>
</template>

<script>
	import { getArticleAll } from '../../util/request/article.js'
 	export default {
		data() {
			return {
				title: 'Hello',
				articleList: []
			}
		},
		onLoad() {
			
		},
		mounted() {
			this.getArticle();
		},
		methods: {
			/**
			 * 获取所有文章列表
			 */
			getArticle() {
				let that = this;
				getArticleAll().then(res=>{
					if(res.code===200) {
						this.articleList = res.list;
					}
				})
			},
			/**
			 * 跳转到详情
			 */
			gotoDetail(id) {
				uni.navigateTo({
				    url: '/blog/article/detail/index?id='+id
				});
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	.wrap{
		display: flex;
		flex-direction: column;
		justify-content: center;
		height: 100%;
		
		.content{
			background-color: #fff;
			display: flex;
			padding:5rpx 24rpx;
			border-bottom:1rpx solid #eee;
			flex-direction: column;
			min-height:200rpx;
			margin-top:10rpx;
			
			.item{
				padding:5rpx 24rpx;
				border-bottom:1rpx solid #eee;
				min-height:200rpx;
				margin-top:10rpx;
				.head{
					
					display: flex;
					flex-direction: row;
					font-size: 24rpx;
						
					image{
						height: 60rpx;
						width: 60rpx;
						margin-right:10rpx;
					}
					
					view{
						display: flex;
						flex-direction: column;
					}
				}
				
				.text_content{
					margin-top: 20rpx;
					font-size:24rpx;
					.content_main{
						.title{
							font-size:28rpx;
							font-weight: bold;
						}
					}
				}
			}
		}
	}
</style>
